package org.hyh.core.controller;

import org.hyh.core.model.vo.ResultVo;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @auther :hyh
 * @desc :
 * @date :2020/7/11
 */
@RestController
@RequestMapping("/train")
public class LoginController {
//    /train/tain-user

    @GetMapping("/train-user")
    public ResultVo    loginFial(HttpServletRequest request,HttpServletResponse response){
         ServletContext servletContext = request.getServletContext();



         return ResultVo.buildFail("train_admin/train_user  can see");
     }

     @GetMapping("/train-admin")
     public  ResultVo loginSuccess(){
         Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
         return ResultVo.buildOkData(principal, "only  train-admin can  see");
     }

    @GetMapping("/all")
     public ResultVo process(String username, String password) {
         return  ResultVo.buildFail("不需要登录就可见！");
     }


}
